﻿using System.Collections.Generic;
using System.ComponentModel;

using Microsoft.Xna.Framework.Graphics;
using MapEditor.Tiles;

namespace MapEditor
{
    public class Map // Mostly a container
    {
        //public List<TileLayer> TileLayers = new List<TileLayer>();

        public TileLayer tileLayer;
        public BindingList<TileType> TileTypes = new BindingList<TileType>();
        

        public Map()
        {

        }

        public Map(Map mapCopy)
        {
            TileTypes = new BindingList<TileType>();

            foreach (TileType tileType in mapCopy.TileTypes)
            {
                TileTypes.Add(new TileType(tileType));
            }

            ArrayTexture = mapCopy.ArrayTexture;

            TilesetTexture = mapCopy.TilesetTexture;

            ActiveLayer = new TileLayer(mapCopy.ActiveLayer);
            
            //TileLayers = new List<TileLayer>();

            //foreach (TileLayer layer in mapCopy.TileLayers)
                //TileLayers.Add(new TileLayer(layer));
        }

        public int ActiveLayerIndex
        {
            get;
            set;
        }

        public Texture2D ArrayTexture
        {
            get;
            set;
        }

        public Texture2D TilesetTexture
        {
            get;
            set;
        }

        public TileLayer CustomLayer
        {
            get;
            set;
        }

        public TileLayer ActiveLayer
        {
            get;
            set;

            //return TileLayers[ActiveLayerIndex];
            //return tileLayer;

        }

        public int Width
        {
            get
            {
                return ActiveLayer.Width;
            }
            set
            {
                ActiveLayer.Width = value;
            }
        }

        public int WidthInPixels
        {
            get
            {
                return ActiveLayer.Width * ActiveLayer.TileSize;
            }
        }

        public int Height
        {
            get
            {
                return ActiveLayer.Height;
            }
            set
            {
                

                ActiveLayer.Height = value;
            }
        }

        public int HeightInPixels
        {
            get
            {
                return ActiveLayer.Height * ActiveLayer.TileSize;
            }
        }

        public int TileSize
        {
            get
            {
                return ActiveLayer.TileSize;
            }
            set
            {

                ActiveLayer.TileSize = value;
            }
        }

        public void Clear()
        {
          

            ActiveLayer.Clear();
        }
    }
}
